<include file="Public/header"/>

<div class="x-nav">
      <span class="layui-breadcrumb">

      </span>
      <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
    </div>
    <div class="x-body">
      <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so" >
           <label class="layui-form-label">活动状态</label>
           <div class="layui-input-inline">
            <select name="status">
              <option value="0" selected='selected'>请选择</option>
              <option value="1" >正常</option>
              <option value="2" >冻结</option>
            </select>
          </div>
		  <input type="text" name="id"  placeholder="请输入活动id" autocomplete="off" value="{:I('id')}" class="layui-input">
          <input type="text" name="name"  placeholder="请输入活动名称" autocomplete="off" value="{:I('name')}" class="layui-input">
          <input type="text" name="periods"  placeholder="请输入活动期数" autocomplete="off" value="{:I('periods')}" class="layui-input">
          <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            <button class="layui-btn"   type="reset" >清空</button>

        </form>
      </div>
      <xblock>
        <a class="layui-btn" onclick="x_admin_show('添加活动','{:U('add')}')">添加活动</a>
        <button class="layui-btn layui-btn-danger" onclick="delAll('','{:U('del')}')"><i class="layui-icon"></i>永久删除</button>
		<!--  <button class="layui-btn layui-btn-warm" onclick="issetAll('','{:U('isnotstatus')}')">批量冻结</button>
		<button class="layui-btn layui-btn-normal" onclick="issetAll('','{:U('isstatus')}')">批量正常</button>-->
        <span class="x-right" style="line-height:40px">共有数据：{$count} 条</span>
      </xblock>
      <table class="layui-table">
        <thead>
          <tr>
            <th>
              <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>团购期数</th>
            <th>活动标题</th>
            <th>活动描述</th>
            <th>团购时间</th>
            <th>提货时间</th>
            <!-- 
            <th>发起者头像</th>
            <th>活动电话</th>
             -->
            <th>活动状态</th>
            <th>自定义排序</th>
            <!--<th>小区限制类型</th>-->
            <th>创建时间</th>
            <th>操作</th>
          </tr>
        </thead>
        <tbody>
        <volist name="list" id="vo">
          <tr>
            <td>
              <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id={$vo['id']}><i class="layui-icon">&#xe605;</i></div>
            </td>
            <td>{$vo['id']}</td>
            <td>{$vo['periods']}</td>
            <td>{$vo['name']}</td>
            <td>{$vo['desc']}</td>
            <td>{$vo['start_time']|date='Y-m-d H:i:s',###}<p>{$vo['end_time']|date='Y-m-d H:i:s',###}</td>
            <td>{$vo['tihuo_start_time']|date='Y-m-d H:i:s',###}<p>{$vo['tihuo_end_time']|date='Y-m-d H:i:s',###}</td>
            <!--  
            <td><img src="{$vo['header']}" style="width: 40px" border=0>{$vo['nickname']}</td>
            <td>{$vo['mobile']}</td>
            -->
            <td>
              <php>
                $text = $vo['status'] == 1 ? '正常':'冻结';
                $class = $vo['status'] == 1 ? 'layui-btn-normal':'layui-btn-danger'
              </php>
              <span   class="layui-btn  layui-btn-xs {$class} " onclick="setStatus(this,'{$vo['id']}','{:U('setStatus')}')">{$text}</span>   
			</td>
            <td>{$vo['sort']}</td>
            <!--<td>{$vo['allow_xiaoqu_ids']}</td>-->
            <td>{$vo["addtime"]|date='Y-m-d H:i:s',###}</td>
            <td>
              <a title="编辑" class="layui-btn layui-btn-xs"  onclick="x_admin_show('活动编辑','{:U('edit',array('id'=>$vo['id']))}')" href="javascript:;">
                编辑
              </a>
              <p>
              <span   class="layui-btn  layui-btn-xs layui-btn-normal " onclick="copyactive(this,'{$vo['id']}','{:U('copyActive')}')">快速复制创建</span>
              <p>

           <a title="编辑活动商品" class="layui-btn layui-btn-xs"  onclick="x_admin_show('编辑活动商品','{:U('goods',array('id'=>$vo['id']))}')" href="javascript:;">
               编辑活动商品
              </a>
              <p>
              <!--  
           <a title="编辑活动小区" class="layui-btn layui-btn-xs"  onclick="x_admin_show('编辑活动小区','{:U('xiaoqu',array('id'=>$vo['id']))}')" href="javascript:;">
              编辑活动小区
              </a>
              <p>-->
            </td>
          </tr>
        </volist>


        </tbody>
      </table>
      <div class="page" id="page">
        {$page}
      </div>

    </div>
    <script>

      layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });

      function issetAll(argument,url){
    	    var data = tableCheck.getData();
    	    
    	    layer.confirm('确认要这样操作吗？',function(index){

    	        if(data == false || data=='undefined'){
    	            layer.msg('参数错误',{icon:5});
    	            return false;
    	        }
    	        $.post(url,{id:data},function (res) {
    	            if(res.code){
    	                layer.msg(res.msg,{icon:5});
    	            }else{

    	                layer.msg('操作成功', {icon: 1});
    	                location.replace(location.href);
    	            }

    	        })

    	    });
      }
      /*快速复制活动操作*/
      function copyactive(obj,id,url){
    	    layer.confirm('确认要复制创建吗？',function(index){
    	        if(!id){
    	            layer.msg('参数错误',{icon:5});
    	            return false;
    	        }

    	        $.post(url,{id:id},function (res) {
    	            if(res.code){
    	                layer.msg(res.msg,{icon:5});
    	            }else{
    	                layer.msg('复制成功!',{icon:1,time:1000});
    	                location.replace(location.href);
    	            }

    	        },'json')


    	    });
    	}      
       /*用户-停用*/
      function member_stop(obj,id){
          layer.confirm('确认要停用吗？',function(index){

              if($(obj).attr('title')=='启用'){

                //发异步把用户状态进行更改
                $(obj).attr('title','停用')
                $(obj).find('i').html('&#xe62f;');

                $(obj).parents("tr").find(".td-status").find('span').addClass('layui-btn-disabled').html('已停用');
                layer.msg('已停用!',{icon: 5,time:1000});

              }else{
                $(obj).attr('title','启用')
                $(obj).find('i').html('&#xe601;');

                $(obj).parents("tr").find(".td-status").find('span').removeClass('layui-btn-disabled').html('已启用');
                layer.msg('已启用!',{icon: 5,time:1000});
              }
              
          });
      }





    </script>

<include file="Public/footer"/>

